package io;

import java.io.*;
import java.net.URL;

public class BaiduDemo {

    public static void main(String[] args) throws IOException {

        BufferedReader reader = new BufferedReader(new InputStreamReader(new URL("http://www.baidu.com").openStream()));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("test.html")));
        String msg = null;
        while ((msg = (reader.readLine()))!= null) {
           writer.write(msg);
           writer.newLine();
        }
        writer.close();
        reader.close();
    }
}
